
<%--
  Created by IntelliJ IDEA.
  User: ASUS
  Date: 2024/6/13
  Time: 下午1:49
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %>
<html>
<head>
    <meta charset="UTF-8">
    <title>洪炜斐——学生管理系统——消息</title>
    <link rel="stylesheet" href="./css/common.css">
    <link rel="stylesheet" href="./css/style.css">
    <link rel="stylesheet" href="./css/custom.css">

    <style>
        body {
            box-sizing: border-box;
            padding: 2em;
        }

        main {
            flex: 1;
            display: flex;
            flex-direction: column;
            justify-content: center;
            align-items: center;

            transform: translateY(-10%);
        }
    </style>
</head>
<body>
    <main>

        <%
            String action = request.getParameter("action");
            String message = request.getParameter("message");
            String ms = request.getParameter("ms");
            String time = request.getParameter("time");

            Integer msInt = ms != null ? Integer.parseInt(ms) : time != null ? Integer.parseInt(time) : 0;
        %>
        <% if (message == null || message.isEmpty()) { %>
            <script>
                alert("错误");
                window.history.back();
            </script>
        <% } %>

        <h3><%= message %></h3>
        <br>
        <% if (action != null && action.equals("home")) { %>
            <a href="./index.jsp">点此回到首页</a>
        <% } else { %>
            <a href="javascript: history.back()">点此回到上一页</a>
        <% } %>

        <% if (msInt > 0) { %>
            <br/>
            <p>
                <%= (msInt / 1000.0) %>
                秒后自动回到<%= (action != null && action.equals("home")) ? "首页" : "上一页" %>
            </p>
            <script>
                const action = "<%= action %>";
                setTimeout(() => {
                    if (action === "home") {
                        window.location.href = "./index.jsp";
                    } else {
                        window.history.back();
                    }
                }, <%= msInt %>);
            </script>
        <% } %>

    </main>
</body>
</html>


